<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后台管理系统</title>
    <meta name="author" content="BaiYY"/>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
</head>
<body>
    <div class="right-sidebar" style="max-width: 1200px">
        <ul class="nav nav-tabs" style="margin-bottom: 16px" role="tablist" id="listTab">
            <li role="presentation" class="active"><a href="initSet.html">{:L(GAME_SETTING_INIT)}</a></li>
            <li role="presentation" id="invited"><a href="activityInvite.html">{:L(GAME_SETTING_INVITE)}</a></li>
            <li role="presentation" id="roomd"><a href="activityCreateRoom.html">{:L(GAME_SETTING_ROOM)}</a></li>
            <li role="presentation" id="advd"><a href="advSet.html">{:L(GAME_SETTING_ADV)}</a></li>
            <li role="presentation" id="wheeld"><a href="luckWheel.html">{:L(GAME_SERRING_WHEEL)}</a></li>
        </ul>
        <session>
            <div class="row" >
                <div class="col-md-12">
                    <h3>说明</h3>
                    <p>1、设置新注册用户送{:L(GAME_RESOURCE)}数量</p>
                    <p/>2、设置新注册用户送金币的数量</p>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="input-group">
                                <span class="input-group-addon">{:L(GAME_RESOURCE)}数量</span>
                                <input class="form-control" type="number" name="card" min="1" id="card"/>
                            </div>
                            <div class="input-group">
                                <span class="input-group-addon">金币数量</span>
                                <input class="form-control" type="number" min="1" name="coin" id="coin"/>
                            </div>
                            <p></p>
                            <button class="btn btn-primary center-block" id="submit">设置</button>
                        </div>
                    </div>
                </div>
            </div>
        </session>
    </div>
    <script type="text/javascript">
        $(function () {
            var invited = $.trim($("#invited").text());
            var roomd = $.trim($("#roomd").text());
            var advd = $.trim($("#advd").text());
            var wheeld = $.trim($("#wheeld").text());

            if(invited == '' || invited == 'GAME_SETTING_INVITE') {
                $("#invited").hide();
            }
            if(roomd == '' || roomd == 'GAME_SETTING_ROOM') {
                $("#roomd").hide();
            }
            if(advd == '' || advd == 'GAME_SETTING_ADV') {
                $("#advd").hide();
            }

            if(wheeld == '' || wheeld == 'GAME_SERRING_WHEEL') {
                $("#wheeld").hide();
            }
        });
        $(function () {
            $.ajax({
                type:"json",
                url:"{:U('Admin/Main/uidInit')}",
                success:function (data) {
                    if(data != 'error' && data) {
                        $("#card").val(data.card);
                        $("#coin").val(data.coin);
                    }else if(data == 'error') {
                        alert("请求错误！");
                        window.location.href="{:U('Admin/Main/initSet')}";
                    }
                }
            });
        });
        $("#submit").on("click",function () {
            var card = $.trim($("#card").val());
            var coin = $.trim($("#coin").val());
            var g = /^[1-9]*[1-9][0-9]*$/;

            if(card == '' || coin == '') {
                alert('输入值不能为空！');
                window.location.href="{:U('Admin/Main/initSet')}";
                return false;
            }
            if(!g.test(card) || !g.test(coin)) {
                alert("设置的值必须是正整数！");
                window.location.href = "{:U('Admin/Main/initSet')}";
                return false;
            }

            $.ajax({
                type:"post",
                url:"{:U('Admin/Main/uidInitSet')}",
                dataType:"json",
                data:{"card":card,"coin":coin},
                success:function (data) {
                    if(data == 'success'){
                        alert("设置成功！");
                        window.location.href="{:U('Admin/Main/initSet')}";
                    }else if(data == 'failure') {
                        alert("请求错误,设置失败!");
                        window.location.href="{:U('Admin/Main/initSet')}";
                    }else if(data == 'error') {
                        alert("设置失败！");
                        window.location.href="{:U('Admin/Main/initSet')}";
                    }
                }
            })
        });
    </script>
</body>
</html>